package ar.com.ford.it.fullEconomics.persistence.dao;

import java.util.Collection;
import ar.com.ford.it.fullEconomics.persistence.dto.Ncas003ColorVw;
import ar.com.ford.it.webengine.persistence.PersistenceUtil;
import com.ford.it.logging.ILogger;
import com.ford.it.logging.LogFactory;
import com.ford.it.persistence.PersistenceException;
import com.ford.it.persistence.Transaction;

public class ColorDao extends Dao {

    private static final String CLASS_NAME = ColorDao.class.getName();

    private static final ILogger log = LogFactory.getInstance().getLogger(
            CLASS_NAME);
/**
 * Busca tdoo los colores no se le manda ningun indicador
 * @return
 * @throws PersistenceException
 */
    public Collection findAllColor()
            throws PersistenceException {
        String METHOD_NAME = "findAllColor";
        log.entering(CLASS_NAME, METHOD_NAME);
        Collection result = null;
        result = super.findAll(new Ncas003ColorVw(), null, null);
        log.exiting(CLASS_NAME, METHOD_NAME);
        return result;
    }
/**
 * Obtiene el objeto del color por el id
 * @param code
 * @return
 * @throws PersistenceException
 */
    public Ncas003ColorVw getColorById(String code) throws PersistenceException{
    	Ncas003ColorVw res = null;
        res.setCas003ColorCodeC(code);
        return (Ncas003ColorVw) this.getObjById(res);
    }
    /**
     * Obtiene el objeto para actualizar
     * @param code
     * @return
     * @throws PersistenceException
     */
    public Ncas003ColorVw getColorForUpdate(String code)throws PersistenceException{
    	Ncas003ColorVw res = null;
        res.setCas003ColorCodeC(code);
        return (Ncas003ColorVw) this.getObjForUpdate(res);
    }
    public void createColor(Ncas003ColorVw colorRead) throws PersistenceException {
        Transaction tx = null;
        String METHOD_NAME = "createColor";
        log.entering(CLASS_NAME, METHOD_NAME);
        tx = PersistenceUtil.getTransaction();
        tx.registerInsert(colorRead);
        log.exiting(CLASS_NAME, METHOD_NAME);
    }
}
